import { useState, useEffect } from "react";

const App = () => {
  const [count, setCount] = useState(0);

  useEffect(() => {
    // 操作引入其他代码
    document.title = count;
    // 引入一个计时器
    const timerId = setInterval(() => {
      console.log("我是一个每隔1秒执行一次的定时器，我的Id是：", timerId);
    }, 1000);


    return () => {
      clearInterval(timerId)
      console.log('effect 清除函数执行了')
    }
  });

  return (
    <div>
      <div>{count}</div>
      <button onClick={()=> setCount(count+1)}>修改Count</button>
    </div>
  );
};

export default App;
